﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Apps.Model.Base;

namespace Apps.Model.Models
{
    /// <summary>
    /// 用户表
    /// </summary>
    [Table("Sys_User")]
    public class SysUser : SysBase, IEntity<int>
    {
        /// <summary>
        /// 自增主键
        /// </summary>
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }

        /// <summary>
        /// 用户名
        /// </summary>
        [Required]
        [StringLength(30)]
        [Display(Name = "用户账号")]
        public string UserName { get; set; }

        /// <summary>
        /// 密码 MD5 加密
        /// </summary>
        [Required]
        [StringLength(30)]
        [Display(Name = "密码")]
        public string Password { get; set; }


        /// <summary>
        /// 用户昵称
        /// </summary>
        [Display(Name = "用户昵称")]
        [Required]
        [StringLength(30)]
        public string NickName { get; set; }

        /// <summary>
        /// 电话
        /// </summary>
        [Required]
        [StringLength(20)]
        [Display(Name = "手机号")]
        public string PhoneNumber { get; set; }

        /// <summary>
        /// 用户性别（0男 1女 2未知）
        /// </summary>
        [Display(Name = "用户性别（0男 1女 2未知）")]
        public int Sex { get; set; } = 2;


        /// <summary>
        /// 状态(1正常，0冻结)
        /// 默认值:1
        /// </summary>
        [Display(Name = "状态(0正常 1停用)")]
        public int IsEnable { get; set; } = 0;

        /// <summary>
        /// 状态(1正常，0冻结)
        /// 默认值:1
        /// </summary>
        [Display(Name = "删除标志（0代表存在 1代表删除）")]
        public int IsDeleted { get; set; } = 0;
        /// <summary>
        /// 头像 路径
        /// </summary>
        [StringLength(200)]
        [Display(Name = "头像（路径)")]
        public string? Avatar { get; set; }


        /// <summary>
        /// 邮箱
        /// </summary>
        [StringLength(100)]
        [Display(Name = "邮箱")]
        
        public string Email { get; set; }

        /// <summary>
        /// 最后登录时间
        /// </summary>
        [Display(Name = "最后登录时间")]
        public DateTime? LastLoginTime { get; set; }

        /// <summary>
        /// 连续登录失败次数
        /// </summary>
        [Display(Name = "连续登录失败次数")]
        public int LoginAttempts { get; set; } = 0;
    }
}
